<extend name="./Application/Admin/View/common/base.html" />
<block name="crumb">
    <span class="c-gray en">&gt;</span> 分类管理
    <span class="c-gray en">&gt;</span> 分类列表
</block>
<block name="content">
    <div class="tabBar cl m-b-10">
        <span><a href="{:U('Agent/index')}">代理列表</a></span>
        <span class="current"><a href="{:U('Agent/for_audit')}">待审列表</a></span>
        <span><a href="{:U('Agent/closed')}">已关代理</a></span>
    </div>

    <!-- 搜索 -->
    <div class="text-c">
        <form class="Huiform" method="get" action="" >
            <input type="text" placeholder="姓名/手机" value="{$_GET['mName']}" class="input-text w-150" name="mName"/>
            <select name="rankId" class="input-text search-select">
                <option value="">-- 级别 --</option>
                <foreach name="ranks" item="rank">
                    <option value="{$rank['rank_id']}" <if condition="$_GET['rankId'] eq $rank['rank_id']">selected</if>>{$rank['rank_name']}</option>
                </foreach>
            </select>
            <input type="hidden" name="m" value="admin"/>
            <input type="hidden" name="c" value="agent"/>
            <input type="hidden" name="a" value="for_audit"/>
            <button type="submit" class="btn btn-success"><i class="Hui-iconfont"></i> 查询</button>
        </form>
    </div>

    <div class="mt-10">
        <table class="table table-border table-bordered table-bg table-sort table-hover">
            <form action="{:U('Agent/batchDo')}" method="post" id="batch_do">
                <thead>
                <tr class="text-c">
                    <th><input type="checkbox" id="check_all"/></th>
                    <th>代理姓名</th>
                    <th>手机</th>
                    <th>上级代理</th>
                    <th>注册时间</th>
                    <th>注册IP</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <volist name="agents" id="agent">
                    <tr class="text-c">
                        <td><input type="checkbox" class="check_list" name="agent_id[]" value="{$agent['agent_id']}"/></td>
                        <td>{$agent['agent_name']}</td>
                        <td>{$agent['mobile']}</td>
                        <td>
                            <if condition="$agent['parent_id'] neq '0'">
                                {:GetAgentNameById($agent['parent_id'])}
                                <else/>无
                            </if>
                        </td>
                        <td>{$agent['reg_time']}</td>
                        <td>{$agent['reg_ip']}</td>
                        <td>
                            <span class="label label-danger" onclick="closeAgent({$agent['agent_id']})">关闭</span>
                            <a href="{:U('Agent/agent_audit',array('id'=>$agent['agent_id']))}"><span class="label label-default">审核</span></a>
                        </td>
                    </tr>
                </volist>
                <tr>
                    <td colspan="11">
                        <input type="hidden" name="type" value="" id="do_type"/>
                        <span class="label label-danger changeS" type="button" do="close">关闭</span>
                    </td>
                </tr>
                </tbody>
            </form>
        </table>
    </div>
    <div class="page" style="margin-top: 10px;">{$page}</div>
</block>

<!--自己的css和js-->
<block name="css">
    <link href="__PUBLIC__/Admin/static/ext/css/zoomify.css" rel="stylesheet" type="text/css" />
</block>
<block name="js">
    <script type="text/javascript">
        $(function(){
            $('.changeS').click(function ()
            {
                var do_type = $(this).attr("do");
                layer.confirm('您确认进行此操作吗？', {
                    btn: ['确认','取消']
                }, function(){
                    $("#do_type").attr("value", do_type);
                    $("#batch_do").submit();
                });
            });
        });
        // 关闭用户
        function closeAgent( $agent_id)
        {
            layer.confirm('您确认关闭此用户吗，他将无法再登陆系统？', {
                btn: ['确认','取消']
            }, function(){
                $.ajax({
                    url: "{:U('Agent/closeAgent')}",
                    type: "post",
                    dataType:'JSON',
                    data: {agent_id: $agent_id },
                    beforeSend: function () {
                        layer.msg('关闭中..', {icon: 16,time :500});
                    },
                    success: function (msg)
                    {
                        if(msg.status == 'success'){
                            location.reload(true);
                        }else{
                            layer.alert(msg.msg);
                        }
                    }
                });
            });
        }
    </script>
</block>
